<?php

function ParseXml($strHtml)
{
    $arrConfig = array
    (
        "indent"           => True,
        "output-xml"       => True,
        "wrap"             => 2000,
        "doctype"          => "omit",
        "quote-ampersand"  => False,
        "clean"            => True,
        "drop-empty-paras" => True,
        "quote-nbsp"       => False
    );
    $oTidy = new tidy;
    $oTidy->parseString($strHtml, $arrConfig, "utf8");
    $oTidy->cleanRepair();
    $oXml = simplexml_load_string($oTidy);
    return $oXml;
}
$ins = file("in.txt");
foreach ($ins as $key=>$item)
{
    $arr = explode("|",$item);
    $data[$key]['url'] = xhamster($arr[0]);
    $data[$key]['thumb'] = $arr[1];
    $data[$key]['desc'] = $arr[2];
    $data[$key]['duration'] = $arr[3];
    $data[$key]['tags'] = $arr[4];
    $data[$key]['flv'] = $arr[5];
    $data[$key]['flv1'] = $arr[6];

}
$content = "";
foreach ($data as $item)
{
    $content .= implode("|",$item);
}
file_put_contents("out.txt",$content);
function xhamster ($url)
{
$in = file_get_contents($url);
$out = ParseXml($in);
$script = $out->xpath("//script");
$text = $script[10][0];
$arr = explode(",",$text);
return "http://xhamster.com/flv2/".str_replace("'","",$arr[2]);
}
?>